//=========================================================
// cppTutorConcreteObserverAnalogClock.cpp
//
// Implement member functions in AnalogClock class which
// is in file AnalogClock.h
//=========================================================

#include "cppTutorConcreteObserverAnalogClock.h"

AnalogClock::AnalogClock (ClockTimer *s)
{
    _subject = s;
    _subject->Attach(this);
}

AnalogClock::~AnalogClock ()
{
    _subject->Detach(this);
}

void AnalogClock::Update (Subject *theChangedSubject)
{
    if(theChangedSubject == _subject)
    {
        Draw();
    }
}

void AnalogClock::Draw ()
{
    int hour = _subject->GetHour();
    int minute = _subject->GetMinute();
    int second = _subject->GetSecond();

    cout << "Analog Clock time is " << hour << ":"
         << minute << ":"
         << second << endl;
}
